/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aybolit.core.objects;

import aybolit.core.objects.dao.BedsDao;
import aybolit.core.objects.dao.ChambersDao;
import aybolit.core.objects.model.Beds;
import aybolit.core.objects.model.Chambers;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Masumov Emin
 */
public class ChambersBean implements Serializable {

    BedsDao bedsDao;
    ChambersDao chambersDao;
    private List<Beds> bedslist;
    private boolean flag = false;
    private String chamberName;
    private List<Beds> freeBedsList;
    private String name;
    private String chamberID;

    public int getBuzyBeds(String id) {
        int buzyBeds = 0;
        List<Beds> bedsList = bedsDao.findBedsbyChamberId(id);
        for (Iterator iter = bedsList.iterator(); iter.hasNext();) {
            Beds bed = (Beds) iter.next();
            if (bed.getBedStatusId() == 12) {
                buzyBeds++;
            }
        }
        return buzyBeds;
    }

    public List<Chambers> getChambersList() {
        return chambersDao.findAllChambers();
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public void ShowBeds() {
        setFlag(true);
    }

    public List<Beds> beds(String id, String name) {
        setChamberName(name);
        bedslist = bedsDao.findBedsbyChamberId(id);
        return bedslist;

    }

    public void freeBeds(String id, String name) {
        setChamberName(name);
        setChamberID(id);
//        freeBedsList = bedsDao.findFreeBedsbyChamberId(id);
    }

    public List<Beds> getBedslist() {
        return bedslist;
    }

    public void setBedslist(List<Beds> bedslist) {
        this.bedslist = bedslist;
    }

    public String getChamberName() {
        return chamberName;
    }

    public void setChamberName(String chamberName) {
        this.chamberName = chamberName;
    }


    public void setChambersDao(ChambersDao chambersDao) {
        this.chambersDao = chambersDao;
    }

    public void setBedsDao(BedsDao bedsDao) {
        this.bedsDao = bedsDao;
    }

    public String go() {
        System.out.println("in info");
        if (name != null) {
            if (!name.equals("null") && !name.equals("")) {
                System.out.println("ok!!!!!!!!!!!!" + name);
                return "succes";
            }
        }
        return "error";
    }

    public void go1(String name) {
        this.name = name;
    }

//    public void setName(String name) {
//        this.name = name;
//    }
    public List<Beds> getFreeBedsList() {
        return bedsDao.findFreeBedsbyChamberId(chamberID);
    }

    public void setFreeBedsList(List<Beds> freeBedsList) {
        this.freeBedsList = freeBedsList;
    }

    public String getChamberID() {
        return chamberID;
    }

    public void setChamberID(String chamberID) {
        this.chamberID = chamberID;
    }
    
}
